package com.hdoit.kylin.logical.studentManager.dao.impl;
import java.util.List;

import org.springframework.stereotype.Component;

import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.enums.OrderEnum;
import com.tennetcn.common.utils.FinderExpressionFactory;
import com.hdoit.kylin.logical.studentManager.dao.IDataDao;
import com.hdoit.kylin.logical.studentManager.model.Data;
import com.hdoit.kylin.logical.viewmodel.DataSearch;

/**
* @author luozhicheng
* @email
* @createtime 2017年07月18日 20:14:32
* @comment
*/
@Component
public class DataDaoImpl extends SuperDao<Data> implements IDataDao{
	
	@Override
	public List<Data> queryListByExcelId(DataSearch search){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.addBody("select * from",Data.class)
						.andWhere("excelId=#{excelId}")
						.setParam("excelId", search.getExcelId())
						.addOrder("sortCode", OrderEnum.asc);
		return queryList(finderExpression,search,Data.class);
	}
	
	@Override
	public boolean deleteById(String id){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.delete()
						.from(Data.class)
						.andWhere("id=#{id}")
						.setParam("id", id);
		return delete(finderExpression)>0;
	}
	
	@Override
	public int queryCountById(String id){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.addBody("select count(1) from", Data.class)
						.andWhere("id=#{id}")
						.setParam("id", id);
		return queryCount(finderExpression);
	}
	
	@Override
	public Data queryModelById(String id){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.addBody("select * from", Data.class)
						.andWhere("id=#{id}")
						.setParam("id", id);
		return queryModel(finderExpression);
	}
}